Skip to content

Document ValueError being raised by UUID constructor#144425

Open
Viicos wants to merge 1 commit into
python:mainfrom
Viicos:document-uuid-valueerror
Open

Document ValueError being raised by UUID constructor#144425
Viicos wants to merge 1 commit into
python:mainfrom
Viicos:document-uuid-valueerror

Conversation

@Viicos
Copy link
Copy Markdown
Contributor

@Viicos Viicos commented Feb 3, 2026

This is a trivial improvement that I think doesn't require an issue.


📚 Documentation preview 📚: https://cpython-previews--144425.org.readthedocs.build/

Comment thread Doc/library/uuid.rst
@@ -66,6 +66,7 @@ which relays any information about the UUID's safety, using this enumeration:
UUID(int=0x12345678123456781234567812345678)

Exactly one of *hex*, *bytes*, *bytes_le*, *fields*, or *int* must be given.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also explicitly specify that this raises a TypeError, but I feel like this is generally known that invalid arguments raise TypeErrors?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually:

  • Invalid signature/usage/object types -> TypeError
  • Valid type but invalid data -> ValueError

The only exception I'm aware of is ipaddress which raises TypeErrors a bit everywhere...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum then not documenting ValueError would maybe make sense? I had the correct assumption for TypeError, and wasn't sure for value errors but indeed it makes sense and once you know about this you can just write your try..except blocks from muscle memory

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually fine with documenting this. Sometimes we do document this, sometimes not.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip issue skip news stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants